/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.iss.basket.service;

import com.iss.basket.ajaxModels.Status;
import com.iss.basket.bizLogic.CustomerService;
import com.iss.basket.models.Customers;
import javax.ejb.EJB;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;

/**
 *
 * @author yc
 */
@Path("/Customer")
public class CustomerWebSvc {
    
    @EJB CustomerService service;
    
    @Path("/register")
    @POST
    @Consumes("application/json")
    public Status registerCustomer(Customers c)
    {   
      boolean result = service.registerCustomer(c);
      if(result)
      {
          Status s = new Status();
          s.setError(false);
          return s;
      }
      else
      {
          Status s = new Status();
          s.setError(true);
          s.setErrorMessage("User with this username already exists");
          return s;
      }      
    }
}
